package top.abrsm.service.impl;

import top.abrsm.entity.RefundEntity;
import top.abrsm.mapper.RefundMapper;
import top.abrsm.service.IRefundService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import top.abrsm.util.SnowflakeIdWorker;
import top.abrsm.util.StateEnum;
import top.abrsm.util.StateException;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 退款记录 服务实现类
 * </p>
 *
 * @author WuZH
 * @since 2023-11-18
 */
@Service
public class RefundServiceImpl extends ServiceImpl<RefundMapper, RefundEntity> implements IRefundService {

    @Override
    public RefundEntity saveSingle (RefundEntity refundEntity) {
        refundEntity.setId ( SnowflakeIdWorker.getInstance ().nextStringId () );
        refundEntity.setCreateTime ( new Date () );
        int insert = baseMapper.insert ( refundEntity );
        if ( insert == 0 ) {
            throw new StateException ( StateEnum.INSERT_EXCE );
        }
        return refundEntity;
    }

}
